#!/usr/bin/env ksh
alias GenPass="cksum|awk '{
  A=\"abcdefghijklmnopqrstuvwxyz!@#%^&()\"
  c=sprintf(\"%d\",substr(sprintf(\"%o%d\",\$1,\$1),2,11));
  printf \"%s\",toupper(substr(A,c%26+1,1));
  for(i=1;i<=7;i++){
    c=sprintf(\"%d\",c/10);j=c%6;
    if((j==2&&i<=5)||(Fa!=1&&i==5)){printf \"%s\",substr(A,c%26+1,1);Fa=1;continue}
    if((j==1&&i<=6)||(Fb!=1&&i==6)){printf \"%s\",c%26%10;Fb=1;continue}
    if(j==0||(Fc!=1&&i==7)){printf \"%s\",substr(A,c%8+27,1);Fc=1;continue}
    printf \"%s\",toupper(substr(A,c%26,1));
  }
}'"

# typeset Grantee='SOMDBDEV'
# typeset HostName='dbmdb01'
typeset Grantee=$1
typeset HostName=$2
typeset PassStr=$(echo "${Grantee}@${HostName}#$(date "+%Y%m%d")"|GenPass)

echo ${PassStr}
